//
//  WebViewController.swift
//  Box
//
//  Created by mn on 2025/4/3.
//

import WebKit

class WebViewController: BaseViewController {
    
    private var webView: WKWebView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupView()
        loadURL()
    }
    
    private func setupView() {
        webView = WKWebView(frame: .zero)
        view.addSubview(webView)
        webView.scrollView.contentInsetAdjustmentBehavior = .never
        webView.snp.makeConstraints { make in
            make.top.equalTo(nav.snp.bottom)
            make.left.right.bottom.equalToSuperview()
        }
    }
    let url: String
    init(url: String) {
        self.url = url
        super.init(nibName: nil, bundle: nil)
    }
    
    @MainActor required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    private func loadURL() {
        if let url = URL(string: url) {
            let request = URLRequest(url: url)
            webView.load(request)
        }
    }
}
